class PictureNumLocation(object):
    @classmethod
    def diff_length_num(cls, base_words):
        """
        :param base_words:
        :return:
        """
        # 数字大概50像素的一半，横纵坐标
        location_x = 20
        location_y = 25
        content = []
        for word in base_words:
            number, location = word.get('number'), word.get('location')
            width = location.get('width')
            height = location.get('height')
            left = location.get('left')
            top = location.get('top')
            if len(number) == 1:
                content.append({'number': number, 'location': location})
            elif len(number) == 2:
                # 竖连接
                if int(number) in [14, 25, 36, 47, 58, 69, 80]:
                    content.append({'number': number[0],
                                    'location': {'left': left, 'top': top}})
                    content.append({'number': number[1],
                                    'location': {'left': left, 'top': top + height - location_y}})
                # 横连接
                elif int(number) in [12, 23, 45, 56, 78, 89]:
                    content.append({'number': number[0],
                                    'location': {'left': left, 'top': top}})
                    content.append({'number': number[1],
                                    'location': {'left': left + width - location_x, 'top': top}})
            elif len(number) == 3:
                # 竖连接
                if number in [147, 258, 369, 580]:
                    content.append(
                        {'number': number[0],
                         'location': {'left': left, 'top': location.get('top') + location_y}})
                    content.append(
                        {'number': number[1],
                         'location': {'left': left, 'top': location.get('top') + 1 / 2 * height}})
                    content.append(
                        {'number': number[2],
                         'location': {'left': left,
                                      'top': location.get('top') + height - location_y}})
                elif number in [123, 456, 789]:
                    content.append(
                        {'number': number[0],
                         'location': {'left': left, 'top': top}})
                    content.append(
                        {'number': number[1],
                         'location': {'left': left + 1 / 2 * width, 'top': top}})
                    content.append(
                        {'number': number[2],
                         'location': {'left': left + width - location_x, 'top': top}})
            elif len(number) == 4:
                if number == '2580':
                    content.append(
                        {'number': number[0],
                         'location': {'left': left, 'top': location.get('top') + 25}})
                    content.append(
                        {'number': number[1],
                         'location': {'left': left,
                                      'top': location.get('top') + 3 / 8 * height}})
                    content.append(
                        {'number': number[2],
                         'location': {'left': left, 'top': location.get('top') + 5 / 8 * height}})
                    content.append(
                        {'number': number[3],
                         'location': {'left': left,
                                      'top': location.get('top') + height - location_y}})
        return content
    
    @classmethod
    def calculation_five_location(cls, content):
        """计算5的坐标
        :param content:
        :return:
        """
        return  content.get('number') is not None
